package com.xxwu.springlibrary.config;

import com.xxwu.springlibrary.interceptor.LoginInterceptor;
import org.aopalliance.intercept.Interceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    //配置自定义拦截器
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
        .addPathPatterns("/**")
        .excludePathPatterns("/userController/login")
                .excludePathPatterns("/**/login.html")
                .excludePathPatterns("/**/*.js")
                .excludePathPatterns("/**/*.pic")
                .excludePathPatterns("/**/*.css");
    }
}
